<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

Route::post('get-data',function(){
  $data = [];
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "http://gp.dlcec.cn:8080/cms-core/dataCenter/quotation_rt2.do");
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(['tradeId'=>'297e501855579e82015557a50f330001']));  
  curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  curl_setopt($ch, CURLOPT_USERAGENT,'Input user agent');
  $response = curl_exec($ch);
  $data = json_decode($response,true);
  return response()->json(['status' =>0, 'message'=>'OK' ,'values' => $data], 200, [], JSON_UNESCAPED_UNICODE);
});
